//
//  FGYHeadView.m
//  01 - shop
//
//  Created by ma c on 16/8/17.
//  Copyright (c) 2016年 beijing. All rights reserved.
//

#import "FGYHeadView.h"
#import "Masonry.h"
#import "FGYLangViewController.h"

@interface FGYHeadView ()

@property (strong, nonatomic) UIImageView * backImageView;
@property (strong, nonatomic) UIButton * landingBtn, * loginBtn;

@end

@implementation FGYHeadView


- (UIImageView *)backImageView{
    if (!_backImageView) {
        _backImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"我的背景"]];
    }
    return _backImageView;
}

- (UIButton *)landingBtn{
    if (!_landingBtn) {
        _landingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_landingBtn setTitle:@"注册" forState:UIControlStateNormal];
        _landingBtn.titleLabel.font = [UIFont systemFontOfSize:18.0];
        [_landingBtn setBackgroundColor:[UIColor clearColor]];
        
        [_landingBtn addTarget:self action:@selector(pushLandViewController) forControlEvents:UIControlEventTouchUpInside];
        
    }
    return _landingBtn;
}

- (void)pushLandViewController{
    if (_pushBlock) {
        self.pushBlock();
    }

}

- (UIButton *)loginBtn{
    if (!_loginBtn) {
        _loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_loginBtn setTitle:@"登陆" forState:UIControlStateNormal];
        _loginBtn.titleLabel.font = [UIFont systemFontOfSize:18.0];
        [_loginBtn setBackgroundColor:[UIColor clearColor]];
    }
    return _loginBtn;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.backImageView];
        [self addSubview:self.landingBtn];
        [self addSubview:self.loginBtn];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    __weak typeof(self) weekSelf = self;
    [_backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(weekSelf);
    }];
    
    [_loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weekSelf.mas_centerY);
        make.centerX.equalTo(weekSelf.mas_centerX).offset(60);
        make.size.mas_equalTo(CGSizeMake(45, 23));
    }];
    
    [_landingBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weekSelf.mas_centerY);
        make.centerX.equalTo(weekSelf.mas_centerX).offset(-60);
        make.size.mas_equalTo(CGSizeMake(45, 23));
        
    }];
    
    
}

@end
